namespace Guia.Elements
{
    using System;
    using System.Windows.Automation;
    using Guia.Elements.PatternServants;
    using Guia.Locator;

    /// <summary>
    /// This class represents a ListBoxItem.
    /// </summary>
    public class ListBoxItem : ComboBoxItem, ISelectionItemMulti
    {
        /// <summary>
        /// Initializes a new instance of the ListBoxItem class. 
        /// </summary>
        /// <param name="automationElement">The AutomationElement representating the ListBoxItem.</param>
        public ListBoxItem(AutomationElement automationElement)
            : base(automationElement)
        {
        }

        /// <summary>
        /// Gets the default-condition to find a control by its type.
        /// </summary>
        public static new SearchCondition ControlTypeCondition
        {
            get { return SearchCondition.ByControlType(ControlType.ListItem); }
        }

        /// <summary>
        /// Adds this ListBoxItem to the selection of its ListBox.
        /// </summary>
        /// <exception cref="InvalidOperationException">An InvalidOperationException is thrown, when the ListBox does not support multiple selection.</exception>
        public void AddToSelection()
        {
            this.SelectionItemServant.AddToSelection();
        }
    }
}